//
//  VIPMallModels.swift
//  LeGou
//
//  Created by lxm on 2022/8/5.
//

import Foundation
import HandyJSON
struct VIPMallModels {
    struct Cate : HandyJSON {
        var id = 0
        var name = ""
        var child : [Cate]?
    }
    
    struct BalanceInfo : HandyJSON {
        var estimateMallMoney = 0.0
        var mallMoney = 0.0
        var withdrawalMallMoney = 0.0
        var mallMoneyFreeze = 0.0
        var totalActivity = 0.0
        var integral = 0.0
    }
    
    struct ActivityH5 : HandyJSON {
        var id: Int = 0
        var time: Int = 0
        var type = ""
    }

    struct Goods : HandyJSON {
        var ficti: Int = 0
        var flatPattern = ""
        var id: Int = 0
        var image = ""
        var price = 0.0
        var sales: Int = 0
        var stock: Int = 0
        var storeName = ""
        var unitName = ""
        var giveActivity = 0.0
        var storeInfo = ""
        var activityH5 : ActivityH5?
        var buyState = false
        var integralPrice = 0.0
        // 0创客 1 知识 2自营   4积分兑换 5竞购订单"
        var type = 0
        
        mutating func mapping(mapper: HelpingMapper) {
            mapper <<<
                self.price <-- ["price","integralPrice"]
        }
    }
    
    
    struct GoodsDetailResponse : HandyJSON {
        var productInfo = GoodsDetail()
        var productAttr : [ProductAttr]?
        var productValue : [String : Any]?
    }
    
    struct GoodsDetail : HandyJSON {
        // 0创客 1 知识 2自营
        var type = 0
        var activity = ""
        var addTime: Int = 0
        var barCode = ""
        var browse: Int = 0
        var cateId = ""
        var codePath = ""
        var content = ""
        var cost: Int = 0
        var ficti: Int = 0
        var flatPattern = ""
        var giveActivity : Double = 0
        var giveIntegral: Int = 0
        var id: Int = 0
        var image = ""
        var isBargain: Bool = false
        var isBenefit: Bool = false
        var isBest: Bool = false
        var isDel: Bool = false
        var isGood: Bool = false
        var isHot: Bool = false
        var isNew: Bool = false
        var isPostage: Bool = false
        var isRecycle: Bool = false
        var isSeckill: Bool = false
        var isShow: Bool = false
        var isSub: Bool = false
        var keyword = ""
        var merId: Int = 0
        var merUse: Bool = false
        var otPrice: Int = 0
        var postage: Int = 0
        var price = 0.0
        var sales: Int = 0
        var sliderImage = ""
        var sort: Int = 0
        var soureLink = ""
        var specType: Bool = false
        var stock: Int = 0
        var storeInfo = ""
        var storeName = ""
        var tempId: Int = 0
        var unitName = ""
        var videoLink = ""
        var vipPrice: Int = 0
        var integralPrice = 0.0
    }
    
    struct ProductAttr : HandyJSON {
        var productId = 0
        var id = 0
        var attrValues = ""
        var attrName = ""
        var type = 0
    }
    
    struct OrderInfoDetailVo : HandyJSON {
        // 0创客 1 知识 2自营   4积分兑换 5竞购订单"
        var type = 0
        var attrValueId: Int = 0
        var giveActivity : Double = 0
        var giveIntegral: Int = 0
        var image = ""
        var isReply: Int = 0
        var isSub: Bool = false
        var payNum: Int = 0
        var price: Int = 0
        var productId: Int = 0
        var productName = ""
        var productType: Int = 0
        var sku = ""
        var tempId: Int = 0
        var vipPrice: Int = 0
        var volume: Int = 0
        var weight: Int = 0
        var integralPrice = 0.0
    }

    struct OrderInfoVo    : HandyJSON {
        var addressId: Int = 0
        var city = ""
        var detail = ""
        var district = ""
        var orderProNum: Int = 0
        var payFee: Int = 0
        var phone = ""
        var proTotalFee = 0.0
        var integralPrice = 0.0
        var province = ""
        var realName = ""
        var remark = ""
        var orderInfoDetailVo = OrderInfoDetailVo()
    }

    // 预下单详情
    struct PreOrderDetial : HandyJSON {
        var aliPayStatus = ""
        var orderInfoVo = OrderInfoVo()
        var payWeixinOpen = ""
        var preOrderNo = ""
    }
        
    // 订单详情
    struct Info : HandyJSON {
        var attrValueId: Int = 0
        var giveActivity : Double = 0
        var giveIntegral: Int = 0
        var image = ""
        var isReply: Int = 0
        var isSub: Bool = false
        var payNum: Int = 0
        var price: Int = 0
        var productId: Int = 0
        var productName = ""
        var productType: Int = 0
        var sku = ""
        var tempId: Int = 0
        var vipPrice: Int = 0
        var volume: Int = 0
        var weight: Int = 0
    }
    // 订单内商品
    struct OrderInfoListItem : HandyJSON {
        var attrId: Int = 0
        var cartNum: Int = 0
        var image = ""
        var isReply: Int = 0
        var price = 0.0
        var productId: Int = 0
        var proTotalPrice = 0.0
        var sku = ""
        var storeName = ""
    }
    
    // 订单内详情
    struct StoreOrder : HandyJSON {
        var backIntegral: Int = 0
        var bargainId: Int = 0
        var bargainUserId: Int = 0
        var beforePayPrice: Int = 0
        var clerkId: Int = 0
        var combinationId: Int = 0
        var cost: Int = 0
        var couponId: Int = 0
        var couponPrice: Int = 0
        var createTime = ""
        var deductionPrice: Int = 0
        var deliveryCode = ""
        var deliveryId = ""
        var deliveryName = ""
        var deliveryType = ""
        var freightPrice: Int = 0
        var gainIntegral: Int = 0
        var id: Int = 0
        var isAlterPrice: Bool = false
        var isChannel: Int = 0
        var isDel: Bool = false
        var isMerCheck: Int = 0
        var isRemind: Bool = false
        var isSystemDel: Bool = false
        var mark = ""
        var merId: Int = 0
        var orderId = ""
        var outTradeNo = ""
        var paid: Bool = false
        var payPostage: Int = 0
        var payPrice = 0.0
        var payTime = ""
        var payType = ""
        var pinkId: Int = 0
        var proTotalPrice: Int = 0
        var realName = ""
        var refundPrice: Int = 0
        var refundReason = ""
        var refundReasonTime = ""
        var refundReasonWap = ""
        var refundReasonWapExplain = ""
        var refundReasonWapImg = ""
        var refundStatus: Int = 0
        var remark = ""
        var seckillId: Int = 0
        var shippingType: Int = 0
        var status: Int = 0
        var storeId: Int = 0
        var totalNum: Int = 0
        var totalPostage: Int = 0
        var totalPrice = 0.0
        var type: Int = 0
        var uid: Int = 0
        var updateTime = ""
        var useIntegral: Int = 0
        var userAddress = ""
        var userPhone = ""
        var verifyCode = ""
    }
    
    enum OrderType : Int, HandyJSONEnum {
        /// 创客商城
        case vipMall = 0
        /// 知识付费
        case lesson = 1
        /// 自营商城
        case selfMall = 2
        /// 积分兑换
        case integral = 4
        /// 竞购
        case auction = 5
        /// 合成订单
        case compound = 6
        /// 自动退款
        case autoRefund = 7
    }
    
    // 订单详情
    struct OrderDetial : HandyJSON {
        var activityType = ""
        var bargainId: Int = 0
        var createTime = ""
        var customerWechat = ""
        var deliveryId = ""
        var deliveryName = ""
        var deliveryType = ""
        var id: Int = 0
        var offlinePayStatus: Int = 0
        var orderId = ""
        var orderInfoList = [OrderInfoListItem]()
        var orderStatus = ""
        var paid: Bool = false
        var payPostage: Int = 0
        var payPrice = 0.0
        var payTime = ""
        var pinkId: Int = 0
        var refundStatus: Int = 0
        var shippingType: Int = 0
        var status : OrderStatus = .waitSend
        var statusPic = ""
        var storeId: Int = 0
        var totalNum: Int = 0
        var type: Int = 0
        var verifyCode = ""
//        var storeOrder = StoreOrder()
        var payEndTime = ""
        var userAddress = ""
        var userPhone = ""
        var realName = ""
        var takeTime = ""
        // 支付类型
        var payTypeStr = ""
        /// "订单类型：0创客优选 1知识付费 2自营商城  4积分兑换 5竞购订单"
        var orderType : OrderType = .vipMall
        // 课程详情
        var downloadLink = ""
        var password = ""
        
        var payIntegral = 0.0
        
        // 0 食物 1 积分 --竞购订单
        var giveType = 0
        
        var gainActivity = 0.0
        
        var totalPrice = 0.0
        
        var proTotalPrice = 0.0
        var showStatus : ShowStatus {
            get {
                if paid == false {
                    return .unpay
                } else {
                    return ShowStatus.init(rawValue: status.rawValue) ?? .complete
                }
            }
        }
        
        func timeDiss() -> (h : Int, m : Int, s : Int)? {
            guard let end = Double(payEndTime.zm.stringToTimeStamp()) else {return nil}
            let dis = end - nowTimeNodiss()
            if dis > 0 {
                let s = Int(dis) % 60
                let m = Int(dis) / 60 % 60
                let h = Int(dis) / 60 / 60
                return (h, m, s)
            } else {
                return nil
            }
        }
        // 时间差
        var diss : Double = 0.0
        // 当前时间没有时差的
        func nowTimeNodiss() -> Double {
            return Date().timeIntervalSince1970 + self.diss
        }
    }
    
    enum OrderStatus : Int, HandyJSONEnum{
        // 待发货
        case waitSend = 0
        // 待收货
        case waitReceive = 1
        // 已收货
        case received = 2
        // 待评价
//        case unEvaluate = 3
        // 已收货
        case complete = 3
        
        // 待确认
        case waitConfirm = 4
    }
    
    // 用于前端展示的状态
    enum ShowStatus : Int {
        // 待支付
        case unpay = -1
        // 待发货
        case waitSend = 0
        // 待收货
        case waitReceive = 1
        // 已收货
        case complete = 3
        
        // 待确认
        case waitConfirm = 4
        
        func des() -> (title : String, color : UIColor) {
            switch self {
                case .unpay:
                    return (title : "待付款", color : Style.mainColor)
                case .waitSend:
                    return (title : "等待发货", color : Style.mainColor)
                case .waitReceive:
                    return (title : "等待收货", color : UIColor.zm.color333333())
                case .complete:
                    return (title : "完成", color : UIColor.zm.color999999())
                case .waitConfirm:
                    return (title : "待确认", color : UIColor.zm.color999999())
            }
        }
    }
}


